 
		 **************************************************************
		 **															 **
		 ** Paper: Freedom of Foreign Movement and Human Trafficking **
		 **														     **
		 ** Authors: Sam R. Bell & Richard W. Frank 				 **
		 **															 **
		 ** Date: May 11, 2021										 **
		 **															 **
		 ** Task: Figure 3-CIRI freedom of foreign movement map		 **
		 **															 **
		 **************************************************************
 
			
	** This is a do file to merge country-level data with QGIS country-level codes **
 
	clear
	version 16.1
	set seed 1234
 
	** first you need to keep just the year you want to map **
 	
	use "CIRI 2011.dta", clear
	tab year
	keep if year==2011
	sort cow 
	duplicates report cow year
	rename cow ccode
	save "CIRI 2011 only.dta", replace
	 
	** then opening the ccode to world border name file 
		
	import excel "world borders ccode zipper.xlsx", sheet("world borders ccode zipper") firstrow clear
 
	** then you merge in the country-level data you want to map **

	merge m:1 ccode using  "CIRI 2011 only.dta"
	drop polity unctry unreg physint ciri cyr old_empinx unsubreg old_move old_relfre _merge
	order ADMIN ctry country_name
	sort ccode
	
	replace ADMIN=ctry if ADMIN=="" & ctry~=""
	replace ADMIN=country_name if ADMIN=="" & country_name~=""	
	drop country_name ctry
	drop if ccode==.
	
	*replace formov=. if formov==-77
	*replace dommov=. if dommov==-77
 
	** export a csv to add as a layer in QGIS **
		
	export delimited using "formov 2011.csv", replace

	
	
	
	
